//
//  MVTableViewCell.m
//  23-QQ音乐MV作业讲解
//
//  Created by mafeng on 16/8/15.
//  Copyright © 2016年 mafeng. All rights reserved.
//

#import "MVTableViewCell.h"
#import "MVCollectionViewCell.h"
#import "MVConllectionList.h"

#define kMVCollectionViewCell @"collectionViewCell"
@interface MVTableViewCell ()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>

@property (weak, nonatomic) IBOutlet UICollectionView *MVCollectionView;

@end

@implementation MVTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

// 协议方法
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return _mvListArray.count;
}

- (void)setMvListArray:(NSArray<MVConllectionList *> *)mvListArray {
    _mvListArray = mvListArray;
    [_MVCollectionView reloadData];
}

- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    MVCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kMVCollectionViewCell forIndexPath:indexPath];
    cell.mvConllectionList = _mvListArray[indexPath.row];
    return cell;
}

// 改变cell的大小
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        NSLog(@"%@", NSStringFromCGRect(self.bounds));
        return CGSizeMake(CGRectGetWidth(collectionView.bounds), CGRectGetHeight(collectionView.bounds) / 2 - 15);
    }
     return CGSizeMake((CGRectGetWidth(collectionView.bounds) - 5) / 2, CGRectGetHeight(collectionView.bounds) / 4);
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
